home *** CD-ROM | disk | FTP | other *** search
- /* $Revision Header *** Header built automatically - do not edit! ***********
- *
- * (C) Copyright 1991 by Torsten Jürgeleit
- *
- * Name .....: files_test.c
- * Created ..: Thursday 19-Dec-91 20:01:01
- * Revision .: 0
- *
- * Date Author Comment
- * ========= ==================== ====================
- * 11-Apr-92 Torsten Jürgeleit changed line too long error msg
- * 19-Dec-91 Torsten Jürgeleit Created this file!
- *
- ****************************************************************************
- *
- * Test for text file functions
- *
- * $Revision Header ********************************************************/
-
- /* Includes */
-
- #include <exec/types.h>
- #ifdef AZTEC_C
- #include <functions.h> /* needed for Aztec C - prototypes and pragmas for all Amiga system functions */
- #endif
- #include <libraries/memwatch.h> /* header file for memory debug link library (Fish 240) - AFTER functions.h */
- #include <stdio.h>
- #include "files.h"
-
- /* Defines */
-
- #define FILE_NAME "test_file"
- #define FILE_READ_BUFFER_SIZE 2000
- #define FILE_LINE_BUFFER_SIZE 100
- #define FILE_FLAGS (TEXT_FILE_FLAG_TRIM_LINE | TEXT_FILE_FLAG_SKIP_COMMENTS | TEXT_FILE_FLAG_SKIP_EMPTY_LINES | TEXT_FILE_FLAG_LINE_CONTINUATION)
-
- /* Text file test */
-
- LONG
- main(VOID)
- {
- struct FileData *fd;
- BYTE *error = NULL;
- LONG arg1, arg2;
-
- MWInit((BPTR)NULL, 0L);
- if (!(fd = open_text_file(FILE_NAME, FILE_READ_BUFFER_SIZE,
- FILE_LINE_BUFFER_SIZE, FILE_FLAGS))) {
- error = "Can't open file `%s'\n";
- arg1 = (LONG)FILE_NAME;
- } else {
- SHORT status;
-
- do {
- switch(status = read_text_line(fd)) {
- case TEXT_FILE_STATUS_NORMAL :
- printf("Line %d: `%s'\n", fd->fd_LineNum, fd->fd_Line);
-
- case TEXT_FILE_STATUS_EOF :
- break;
-
- case TEXT_FILE_ERROR_LINE_TOO_LONG :
- error = "Line %ld too long (>%ld)\n";
- arg1 = fd->fd_LineNum;
- arg2 = FILE_LINE_BUFFER_SIZE;
- break;
-
- case TEXT_FILE_ERROR_NO_COMMENT_END :
- error = "Missing end of comment `*/' in line %ld\n";
- arg1 = fd->fd_LineNum;
- break;
-
- case TEXT_FILE_ERROR_READ_FAILED :
- error = "Error while reading\n";
- break;
- }
- } while (status == TEXT_FILE_STATUS_NORMAL);
- close_text_file(fd);
- }
- if (error) {
- printf(error, arg1, arg2);
- }
- MWTerm();
- return(0L);
- }
-